//
//  CollectionMoveViewController.swift
//  SwiftTest
//
//  Created by 齐凯 on 2020/6/18.
//  Copyright © 2020 QiKai. All rights reserved.
//

import UIKit

class CollectionMoveViewController: UIViewController,UICollectionViewDelegate,UICollectionViewDataSource {

    struct collectionINdentifier {
      static let cellIdentifier = "cellIdentifier"
        
    }
    

    var collecT:UICollectionView!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = "动态加载collection"
        self.creatUI()
    }
    func creatUI(){
//        let width = (KscreenWidth - 5*2 - 5*2 )/3
//        let falowlayout = UICollectionViewFlowLayout.init()
//        falowlayout.itemSize = CGSize(width: width, height: 40)//cell高度不能比collectionView高度高
//        falowlayout.minimumLineSpacing = 10
//        falowlayout.minimumInteritemSpacing = 5
//        falowlayout.scrollDirection = .vertical
//        falowlayout.sectionInset = UIEdgeInsets.init(top: 5, left: 5, bottom: 5, right: 5)
//
        let flow =  MycollectionViewLayout.init()
        self.collecT = UICollectionView.init(frame: CGRect.null, collectionViewLayout: flow)
        self.collecT.delegate = self;
        self.collecT.dataSource = self
        self.collecT.register(MovieCollectionViewCell.self, forCellWithReuseIdentifier: collectionINdentifier.cellIdentifier)
        self.view.addSubview(self.collecT);
        self.collecT.snp.makeConstraints { (make) in
            make.edges.equalTo(0)
        }
        if #available(iOS 11.0, *) {
            UIScrollView.appearance().contentInsetAdjustmentBehavior = UIScrollView.ContentInsetAdjustmentBehavior.never
        } else {
            self.automaticallyAdjustsScrollViewInsets = false
        }
    }

}
extension CollectionMoveViewController{
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return 100
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let mov:MovieCollectionViewCell = collectionView.dequeueReusableCell(withReuseIdentifier: collectionINdentifier.cellIdentifier, for: indexPath) as! MovieCollectionViewCell
        
        mov.data = indexPath.row
        return mov;
        
    }
}




